<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js" type="text/javascript">
			
		</script>
	</head>
	<body>
		<div id="app">
			<cn :cmovies="movies" :cmessage="message"></cn>
			
		</div>
		
		<template id="temp">
			<div>
			{{cmessage}}
			<ul>
				<li v-for="item in cmovies">{{item}}</li>
			</ul>
			</div>
			
		</template>
		
		<script type="text/javascript">
			
			const cn = {
				template:"#temp",
				// props:["cmessage"],
				//父传子
				//另一种写法，可以限制类型、设置默认、要求必传
				props:{
					cmessage:{
						type:String,
						default:"默认文字",
						required:true,
					},
					cmovies:{
						type:Array,
						default(){
							return[]
						}
					}
				},
			}
			
			const app = new Vue({
				el:"#app",
				data:{
					message:"电影列表",
					movies:["电影1","电影2","电影3"],
				},
				components:{
					cn,
				}
			})
		</script>
	</body>
</html>
